package com.vmove.childtrain.protocol;


import com.vmove.childtrain.utils.ByteUtil;

/**
 * 给adapter设置padid命令
 */
public class PadIDCMD extends AbsProtocol implements Cloneable{

    public PadIDCMD() {
        setDataType(CommandType.COMMAND_PADID);
    }

    public Object clone() throws CloneNotSupportedException{
        return super.clone();
    }

    byte b0=0x00;//预留
    byte b1=0x00;//预留
    byte b2=0x00;//预留
    byte b3=0x00;//预留
    byte b4=0x00;//padid低八位
    byte b5=0x00;//padid高八位
    byte b6=0x00;//预留
    byte b7=0x00;//预留


    public PadIDCMD setPadId(short id){
        byte[] bytes = ByteUtil.getBytes1(id);
        b4 = bytes[0];
        b5 = bytes[1];
        return this;
    }

    public PadIDCMD setPadId(int id){
        byte[] bytes = ByteUtil.getBytes1(id);
        b4 = (byte) (id & 0xff);
        b5 = (byte) ((id & 0xff00) >> 8);
        return this;
    }

    @Override
    public byte[] getBytes() {
        data = new byte[]{b0,b1,b2,b3,b4,b5,b6,b7};
        return super.getBytes();
    }
}
